﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _5___OrderBy
{
    class Student
    {
        public string first;
        public string second;
        public int age;

        public Student(string a, string b, int c)
        {
            first = a;
            second = b;
            age = c;
        }
    }   

    class Program
    {
        static void Main(string[] args)
        {
            List<Student> list = new List<Student>();
            list.Add(new Student("Aesho", "Fubev", 22));
            list.Add(new Student("Pesho", "Bubev", 27));
            list.Add(new Student("Pesho", "Subev", 22));
            list.Add(new Student("Aesho", "Cubev", 15));
            list.Add(new Student("Mesho", "Oubev", 23));
            list.Add(new Student("Xesho", "Bubev", 11));

            var secondList = list.OrderBy(x => x.first).ThenBy(x => x.second);
            foreach (var item in secondList)
            {
                Console.WriteLine("{0} {1}", item.first, item.second);
            }
            Console.WriteLine();

            foreach (var item in list)
            {
                Console.WriteLine("{0} {1}", item.first, item.second);
            }
            Console.WriteLine();

            var thirdList =
                from name in list
                orderby name.first, name.second
                select name;
            foreach (var item in thirdList)
            {
                Console.WriteLine("{0} {1}", item.first, item.second);
            }
        }
    }
}
